import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import '../../AppConfig/Config.dart';
import '../../http/NoLoadingGetApi.dart';

class PersonalInformationDownload extends StatefulWidget {
  const PersonalInformationDownload({super.key});

  @override
  State<PersonalInformationDownload> createState() => _PersonalInformationDownloadState();
}

class _PersonalInformationDownloadState extends State<PersonalInformationDownload> {
  Map userMap={};
  String emailStr="";
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    getUserInfo();
  }
  void getUserInfo(){
    NoLoadinggetApiManager.getData(
      context, // 上下文对象，用于显示提示信息等
      'api/auth/shipper/user/getLoginUser', // 您的API端点
      {}, // 查询参数，如果没有可以传递null
          (responseData)  {
        setState(() {
          userMap=responseData['data'];
        });
      },
    );
  }
  @override
  Widget build(BuildContext context) {
    final screenSize = MediaQuery.of(context).size;
    return Scaffold(
      backgroundColor: MyColors.backgreyColor,
      appBar: AppBar(
        centerTitle: true,
        backgroundColor: Colors.white,
        leading: IconButton(icon: Icon(Icons.arrow_back_ios,color: Colors.black,),onPressed: (){Navigator.pop(context);},),
        title: Text("个人信息下载",style: TextStyle(fontWeight: FontWeight.w300,fontSize: 16.sp),),
      ),
      body: Column(
        children: [
          Expanded(
            child:userMap.isEmpty?Container(): ListView(
            children: [
              Container(
                padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.h,bottom: 10.h),
                color: Colors.white,
                child: Column(
                  crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                      Text("个人信息",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                      SizedBox(height: 10.h,),
                      Center(
                        child:   Container(
                          width: 60.w,
                          height: 60.h,
                          child:
                          userMap['avatarPath']!=null&&userMap['avatarPath']!=""?
                          CircleAvatar(
                            radius: 15,
                            backgroundImage: NetworkImage(MyServiceUrl.imgHeader +userMap['avatarPath']),
                          )
                              :  CircleAvatar(
                            radius: 15,
                            backgroundImage: AssetImage("lib/Images/login/默认头像.jpeg"),
                          ),
                        ),
                      ),
                    SizedBox(height: 10.h,),
                    Row(
                      children: [
                        Text("账号名称",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                        SizedBox(width: 40.w,),
                        Text(userMap['realName'],style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                      ],
                    ),
                    SizedBox(height: 4.h,),
                    Row(
                      children: [
                        Text("手机号码",style: TextStyle(color: MyColors.textColor,fontSize: 14.sp),),
                        SizedBox(width: 40.w,),
                        Text(userMap['phoneNum'],style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                      ],
                    ),
                  ],
                ),
              ),
            Container(
              margin: EdgeInsets.only(top: 8.h),
              padding: EdgeInsets.only(left: 10.w,right: 10.w,top: 10.h,bottom: 10.h),
              color: Colors.white,
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                  children: [
                    Text("下载设置",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                    Text("我们将在1个工作日内将文件发送至您的邮箱",style: TextStyle(color: MyColors.textColor,fontSize: 12.sp),),
                    SizedBox(height: 4.h,),
                    Container(
                      padding: EdgeInsets.only(left: 4.w,right: 4.w),
                      decoration: BoxDecoration(
                        color: MyColors.backgreyColor,
                        borderRadius: BorderRadius.all(Radius.circular(10)),
                      ),
                      child: Row(
                        children: [
                          Text("邮箱地址",style: TextStyle(color: Colors.black,fontSize: 14.sp),),
                          Container(
                              width: screenSize.width-210.w,
                              child:TextField(
                                      decoration: InputDecoration(
                                        hintText: '请输入邮箱地址',
                                        hintStyle:TextStyle(fontSize: 14.sp,color: MyColors.hintColor),
                                        filled: true,
                                        fillColor:MyColors.backgreyColor,
                                        border: InputBorder.none,
                                        alignLabelWithHint: true,

                                        // contentPadding: EdgeInsets.symmetric(vertical: 6.0.h, horizontal: 0.0.w),
                                      ),
                                      keyboardType: TextInputType.number,
                                      textAlign: TextAlign.left,
                                      style: TextStyle(color: Colors.black),
                                      onChanged: (value) {
                                        setState(() {
                                          emailStr=value;
                                        });
                                      },
                                    ),

                          )
                        ],
                      ),
                    ),
                  ],),
            ),
            ],
          ),
          ),
          Container(
            height: 85.h,
            width: screenSize.width,
            color: Colors.white,
            child: GestureDetector(
              child: Container(
                margin: EdgeInsets.only(left: 15.w,right: 15.w,top: 10.h,bottom: 40.h),
                height: 30.h,
                width: screenSize.width-30.w,
                decoration: BoxDecoration(
                  color: MyColors.themeColor,
                  borderRadius: BorderRadius.all(Radius.circular(30)),
                ),
                child: Center(child: Text("提交",style: TextStyle(color: Colors.white,fontSize: 16.sp,fontWeight: FontWeight.w600),),),
              ),
              onTap: (){

              },
            ),
          ),
        ],
      ),
    );
  }
}
